package com.xxl.job.executor.dto;

import lombok.Data;

import java.io.Serializable;

/**
 * @Author: ZYZ
 * @DateTime: 2020/3/3 16:27
 * @Description:
 */
@Data
public class ResultDto implements Serializable {

    private Boolean success;
    private Integer code;
    private String msg;
    private Object data;

    public static ResultDto success() {
        ResultDto dto = new ResultDto();
        dto.setSuccess(true);
        dto.setCode(0);
        return dto;
    }


    public static ResultDto success(String msg) {
        ResultDto dto = new ResultDto();
        dto.setSuccess(true);
        dto.setCode(0);
        dto.setMsg(msg);
        return dto;
    }

    public static ResultDto success(String msg, Object data) {
        ResultDto dto = new ResultDto();
        dto.setSuccess(true);
        dto.setCode(0);
        dto.setMsg(msg);
        dto.setData(data);
        return dto;
    }

    public static ResultDto error(int code) {
        ResultDto dto = new ResultDto();
        dto.setSuccess(false);
        dto.setCode(code);
        return dto;
    }

    public static ResultDto error(int code, String msg) {
        ResultDto dto = new ResultDto();
        dto.setSuccess(false);
        dto.setCode(code);
        dto.setMsg(msg);
        return dto;
    }

}
